package com.zany.util.quartz;

import java.util.Map;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;

import com.zany.system.vo.ParameterSingleVO;
import com.zany.util.date.DateFormater;
import com.zany.util.param.SysParamKey;
import com.zany.util.quartz.service.JobService;

public class CalculateJob extends org.springframework.scheduling.quartz.QuartzJobBean {
	
	private static Log logger = LogFactory.getLog(CalculateJob.class);
	private JobService jobService;

	public CalculateJob() {
	} 
	
	public void setSession(Map arg0) { 
		// TODO Auto-generated method stub

	}

	public void setJobService(JobService jobService) {
		this.jobService = jobService;
	}

	@Override
	protected void executeInternal(JobExecutionContext arg0)throws JobExecutionException {
		if(logger.isInfoEnabled()){logger.info("CalculateJob.executeInternal()");}
		//活期
		ParameterSingleVO rateVO = new ParameterSingleVO();
		rateVO.setParamCode(SysParamKey.RATE.getKey());		
		Double rate = Double.valueOf(jobService.getParameterSingleDetail(rateVO).getParamVal());
		//1年定期
		ParameterSingleVO rateYear1VO = new ParameterSingleVO();
		rateYear1VO.setParamCode(SysParamKey.RATEYEAR1.getKey());		
		Double rateYear1 = Double.valueOf(jobService.getParameterSingleDetail(rateYear1VO).getParamVal());
		
		jobService.updateFund(rate, rateYear1, DateFormater.getSystemCurrentDateSimple());
		//jobService.updateRate(jobVO);
	}
}
